﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using PH5_2004A.Shopping.DTO;
using PH5_2004A.Shopping.IService;
using PH5_2004A.Shopping.Service;
using PH5_2004A.Shopping.Shared;

namespace PH5_2004A.Shopping.API.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class EmployeeController : ControllerBase
    {
        //EmployeeService service = new EmployeeService();
        //PepoleService service = new PepoleService();

        //依赖注入 （对这个概念了解的，回一个1，不了解的，回一个0）

        ////这是构造函数注入  （如果用了注入的方式，则一定要把这个服务进行注册）
        //PepoleService _service;
        //public EmployeeController(PepoleService service)
        //{
        //    _service  = service;
        //}


        //用的是服务接口(注入)
        IEmployeeService _service;
        public EmployeeController(IEmployeeService service)
        {
            _service = service;
        }

        NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();

        [HttpGet]
        public IActionResult Get()
        {
            ResponseResultDto result = new ResponseResultDto();
            try
            {
                result.Code =  RespsonseResultStatuCodeEnum.Success;//不能随便输入

                logger.Info("这是正确的日志");
                return Ok(result);
            }
            catch (Exception ex)
            {
                logger.Error($"出错了，错误信息为：{ex.Message}");
                return BadRequest(ex.Message);
            }
        }
    }
}
